home *** CD-ROM | disk | FTP | other *** search
-
- /* C O P Y R I G H T N O T I C E : */
- /* Copyright 1986 Eric Jul and Norm Hutchinson. May not be used for any */
- /* purpose without written permission from the authors. */
-
- #include <stdio.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <sys/file.h>
- #include <a.out.h>
-
- #include "Kernel/h/stdTypes.h"
- #include "Kernel/h/system.h"
- #include "Kernel/h/assert.h"
- #include "Kernel/h/ecTypes.h"
- #include "Kernel/h/emTypes.h"
- #include "Kernel/h/map.h"
-
- extern ODTag stdDotoODTag;
- #ifndef NODISK
- extern char nodisk;
- #endif
-
- static Map dotomap = NULL;
-
- DotoFilePtr readDotoFile(filename)
- char *filename;
- {
- DotoFilePtr dotoptr;
- int inf;
- struct stat statbuf;
- ODTag *ptr;
-
- #ifndef NODISK
- if(nodisk) {
- #endif
- return NULL;
- #ifndef NODISK
- } else {
- if (!dotomap) dotomap = Map_Create();
- inf = open(filename, O_RDONLY, 0);
- if (inf == NULL) return NULL;
- if (fstat(inf, &statbuf) != 0) return NULL;
- dotoptr = (DotoFilePtr) emalloc((int)(statbuf.st_size+sizeof(ODTag)));
- Map_Insert(dotomap, (int) dotoptr, (int) dotoptr);
- ptr = (ODTag *) dotoptr;
- *ptr = stdDotoODTag;
- dotoptr = (DotoFilePtr) (ptr+1);
- if (read(inf, (char *) dotoptr, (int)statbuf.st_size) != statbuf.st_size) {
- (void) close(inf);
- emfree((char *)ptr);
- return NULL;
- }
- (void) close(inf);
- if (!isOkDoto(dotoptr)) {
- emfree((char *)ptr);
- return NULL;
- }
- return(dotoptr);
- }
- #endif NODISK
- }
-